package edu.pku.sei.modeler.editpolicies;

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.requests.CreateRequest;

import edu.pku.sei.modeler.edit.policies.DiagramLayoutEditPolicy;
import edu.pku.sei.modeler.model.structure.MetaNode;
import edu.pku.sei.modeler.uml.commands.usecase.UseCaseDiagramElementCreateCommandFactory;

public class SubjectNodeEditPolicy extends DiagramLayoutEditPolicy {
	@Override
	protected Command getCreateCommand(CreateRequest request) {
		MetaNode node = (MetaNode) request.getNewObject();
		MetaNode hostNode = (MetaNode) this.getHost().getModel();
		return UseCaseDiagramElementCreateCommandFactory.INSTANCE.createCommand(node,
				hostNode, ((Rectangle) getConstraintFor(request)));
	}

	@Override
	protected Command getOrphanChildrenCommand(Request request) {
		return UnexecutableCommand.INSTANCE;
	}

}
